package com.tebiecloud.order.server.utils;

import com.tebiecloud.common.utils.StringUtils;

/**
 * 生成编号
 */
public class SequenceUtils {

    static final int DEFAULT_LENGTH = 3;

    public static String getSequence(long seq) {
        String str = String.valueOf(seq);
        int len = str.length();
        if (len >= DEFAULT_LENGTH) {// 取决于业务规模,应该不会到达3
            return str.substring(str.length()-3,str.length());
        }
        int rest = DEFAULT_LENGTH - len;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < rest; i++) {
            sb.append('0');
        }
        sb.append(str);
        return sb.toString();
    }

    public static void main(String[] args) {
        System.out.println(SequenceUtils.getSequence(2));
    }
}
